CREATE OR REPLACE FUNCTION get_trans_id() RETURNS uuid AS $BLOCK$
DECLARE
	trans_id uuid;
BEGIN
	trans_id = get_value('trans_id_'||txid_current());
	IF trans_id IS NULL THEN
		trans_id = uuid_generate_v1();
		perform set_value('trans_id_'||txid_current(), ''||trans_id);
	END IF;
	RETURN trans_id; 
END;
$BLOCK$ language plpgsql;